< previous page page_76 next page >

Page 76
0076-01.jpg
Figure 4.14
With the drop-down list, you cannot type an alternative item.
The combo box has much in common with the list box. Both use the AddItem, RemoveItem, and Clear methods to modify the contents of the list. Both can present a sorted or an unsorted list. Both support the ItemData array and NewIndex property. However, one box can do some things that the other cannot.
The combo box mainly lacks support for multiple selections. The key advantage of the combo box, though, is that it allows the users to enter choices that are not on the list. This feature works like an election ballot, in which you can choose a candidate from the list of those running or write in your own.
note.gif The drop-down list does not support the users' entering choices that are not on the list. Its chief advantage over a simple list box is that it occupies less space. square.gif

The following sections explain how to use the different forms of the combo box. The drop-down list is examined first because it is the simplest of the combo box styles.
Creating a Drop-Down List
A drop-down list functions exactly like a list box. The key difference is that the drop-down list takes up less room on your form. When users want to select an item from the list, they click the down arrow, located to the right of the box, to extend the list. After the drop-down list appears, they then make a selection by clicking the item they want to choose. After the selection is made, the list retracts like a window shade, and the selection appears in the box.
cbox.gif You create a drop-down list by drawing a combo box on the form and then setting the Style property to 2 - Dropdown List. You then can begin adding items to the list by using the List property, just like you did for the list box. However, keep in mind that the users can't add items that are not in the list.
Setting the Initial Choice
Depending on your application, you might want to set the initial item for a combo box. For example, you can set the choice in a program that needs to know your citizenship. You can provide a list of choices but set the initial value to "U.S. Citizen" because that would be the selection of most people in this country.

 
< previous page page_76 next page >